import request from '../utils/request';

/**
 * 删除活动日志
 * @param {string} id
 */
export function deleteUpgradeLogApi(id) {
  return request({
    url: '/upgrade_logs/' + id,
    method: 'delete'
  });
}

/**
 * 批量删除活动日志
 * @param {array} idList 
 */
export function deleteUpgradeLogRangeApi(
  idList
) {
  return request({
    url: '/upgrade_logs',
    method: 'delete',
    data: {
      id_list: idList
    }
  });
}

/**
 * 获取设备列表
 * @param {number} pageIndex 页码下标，默认从0开始
 * @param {number} pageSize 每页大小
 * @param {string} sortType 排序
 * @param {string} orderBy 排序依据
 * @param {number} start 开始时间
 * @param {number} end 结束时间
 * @param {string} level 日志级别
 * @param {string} serialNumber 设备序列号
 * @param {string} keyword 关键字
 * @param {string} method 请求方法
 * @param {string} url 请求url,支持模糊查询
 * @param {string} requestMessage 请求信息
 * @param {string} upgradeStatus 升级状态
 */
export function getUpgradeLogListApi(
  pageIndex,
  pageSize,
  sortType,
  orderBy,
  start,
  end,
  level,
  serialNumber,
  keyword,
  method,
  url,
  requestMessage,
  upgradeStatus
) {
  return request({
    url: '/upgrade_logs',
    method: 'get',
    params: Object.assign(
      {
        page_index: pageIndex,
        page_size: pageSize,
        sort_type: sortType,
        order_by: orderBy,
        start: start,
        end: end
      },
      level ? { level } : null,
      serialNumber ? { serial_number: serialNumber } : null,
      keyword ? { keyword } : null,
      method ? { method } : null,
      url ? { url } : null,
      requestMessage ? { request_message: requestMessage } : null,
      upgradeStatus ? { upgrade_status: upgradeStatus } : null
    )
  });
}
